package com.bbkb.user.service.impl;

import com.bbkb.user.dao.SysMenuMapper;
import com.bbkb.user.domain.SysMenu;
import com.bbkb.user.dto.SysMenuDTO;
import com.bbkb.user.service.ISysMenuService;
import com.bbkb.user.util.UserConvert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysMenuServiceImpl implements ISysMenuService {

    @Autowired
    private SysMenuMapper sysMenuMapper;

    @Override
    public List<SysMenuDTO> getSysMenusByUserId(Long userId) {
        List<SysMenu> sysMenus = sysMenuMapper.getSysMenusByUserId(userId);
        return UserConvert.sysMenu2Dtos(sysMenus);
    }

    @Override
    public List<SysMenuDTO> getAllSysMenus() {
        List<SysMenu> sysMenus = sysMenuMapper.getAllSysMenus();
        return UserConvert.sysMenu2Dtos(sysMenus);
    }

    @Override
    public List<SysMenuDTO> getMenuByRoleId(Long roleId) {
        List<SysMenu> sysMenus = sysMenuMapper.getMenuByRoleId(roleId);
        return UserConvert.sysMenu2Dtos(sysMenus);
    }
}
